<template>
  <view class="container">
    <!-- 标题 -->
    <view class="header">
      <text class="title">近一年刷题/模拟考记录</text>
    </view>

    <!-- 记录列表 -->
    <view class="record-list">
      <view 
        class="record-item" 
        v-for="(item, index) in records" 
        :key="index"
        @click="viewDetail(item)"
      >
			<!-- 负责人手机号 -->
			<!-- <u-cell-item  :title="item.date" :value="item.score"  hover-class="cell-hover-class" @click="changeIphone"></u-cell-item> -->
       <view class="record-date">{{ doformatTime(item.create_time) }}</view>
        <view class="record-info">
					<!-- 0练习 1 模拟 -->
          <text v-if="item.cyctk_type == 1 " class="score">{{ item.cyctk_fenshu }}分，</text>
          <text>用时: {{ item.cyctk_usetime ? cyctk_usetime : 0 }}</text>
          <!-- <text>错题{{ item.wrongCount }}</text> -->
        </view>
        <!-- <u-icon name="arrow-right" color="#999" size="16"></u-icon> -->
      </view>
    </view>
  </view>
</template>

<script>
	import util  from '../../../utils/util'
export default {
  data() {
    return {
      records: [
        {
          id: 1,
          date: '2025-05-20 00:00',
          score: '80',
          time: '00:00',
          wrongCount: 5,
          type: '模拟考'
        },
        {
          id: 2,
          date: '2025-05-20 00:00',
          time: '00:00',
          wrongCount: 0,
          type: '刷题'
        },
        {
          id: 3,
          date: '2025-05-20 00:00',
          time: '00:00',
          wrongCount: 0,
          type: '刷题'
        }
      ],
			datatype: 0,
    }
  },
	onLoad(options) {
		this.datatype = options.datatype	
	},
	onShow() {
		this.selectStudyList()
	},
  methods: {
		selectStudyList() {
			this.$u.api.querystudylist({
				"usercode": uni.getStorageSync('usercode'), ///#从业者的用户code
				"datatype": this.datatype   ///#收藏列表，1错题列表，2练习记录列表
			}).then(res => {
				console.log('list:', res)
				this.records = []
				this.records = res.data.base_info
			})
		},
    viewDetail(record) {
      uni.navigateTo({
        url: `/pages/study/record-detail?id=${record.id}`
      })
    },
		doformatTime(datatime) {
			return util.formatDateTime(datatime)
		}
  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 20rpx;
  background-color: #f7f7f7;
  min-height: 100vh;
}

.header {
  padding: 20rpx 0;
  
  .title {
    font-size: 32rpx;
    font-weight: bold;
    color: #333;
  }
}

.record-list {
  background-color: #fff;
  border-radius: 12rpx;
  overflow: hidden;
}

.record-item {
  display: flex;
	justify-content: space-between;
  align-items: center;
  padding: 25rpx 20rpx;
  border-bottom: 1rpx solid #f0f0f0;
  
  &:last-child {
    border-bottom: none;
  }
  
  .record-date {
    width: 300rpx;
    font-size: 26rpx;
    color: #333;
  }
  
  .record-info {
    flex: 1;
    font-size: 26rpx;
    color: #666;
		text-align: right;
    
    .score {
      color: #2979ff;
      font-weight: bold;
    }
  }
  
  .u-icon {
    margin-left: 10rpx;
  }
}
</style>